﻿namespace SubstringExersice
{
    using System;
    using System.Text;

    public static class MainSubstringExersice
    {
        //// 1.2.16.01. Implement an extension method Substring(int index, int length) for the class StringBuilder that returns new
        //// StringBuilder and has the same functionality as Substring in the class String.

        public static StringBuilder Substring(this StringBuilder var4e, int startIndex, int length)
        {
            StringBuilder resultSubstring = new StringBuilder(length);

            for (int char4e = startIndex; char4e < startIndex + length; char4e++)
            {
                resultSubstring.Append(var4e[char4e]);
            }

            return resultSubstring;
        }

        private static void Main()
        {
            StringBuilder demo = new StringBuilder("Telerik Academy for the win!");
            Console.WriteLine(demo.Substring(0, 7).ToString());
        }
    }
}